import { Button } from 'cc';
import { BasePopup, app, ccbutton, ccclass, ccmodifier } from '../../../extensions/cc-feather/assets/src';

/**
 * - 作者: DoooReyn
 * - 日期: 2023.11.01
 * - 名称: BootPopup
 * - 描述: 启动弹窗
 */
@ccclass()
@ccmodifier('BootPopup')
export class BootPopup extends BasePopup {
    @ccbutton({ func: 'close' }, 'BtnClose')
    btnClose: Button;

    @ccbutton({ func: 'onClicked' }, 'Button')
    btnClicked: Button;

    /** 弹窗被点击时调用 */
    async onClicked() {
        await app.view.hint.alert.addTip({
            confirmText: 'Confirm',
            rejectText: 'Cancel',
            tip: 'Everything is ready. It is time to go.\nRestart?',
            title: 'Hello World',
            path: 'prefab/AlertCommon',
            onConfirm: async () => {
                await this.close();
                await app.reset();
            },
            onReject: async () => {
                await this.close();
            },
        });
    }

    protected async onUIStackClicked(): Promise<void> {
        await this.close();
    }
}
